package com.xujl.mvcbind.util;

import android.util.Log;

import java.util.HashMap;
import java.util.Map;

public class TimeLog {
    private static final String TAG = "TimeLog>>>";
    private static final Map<String, Long> CACHE_MAP = new HashMap<>();

    public static void logStart (String tag) {
        CACHE_MAP.put(tag, System.currentTimeMillis());
        Log.w(TAG + tag, ">>>start<<<");
    }

    public static void logEnd (String tag) {
        if (!CACHE_MAP.containsKey(tag)) {
            Log.w(TAG + tag, ">>>not containsKey<<<");
            return;
        }
        final Long startTime = CACHE_MAP.remove(tag);
        if (startTime == null) {
            Log.w(TAG + tag, ">>>startTime is null<<<");
            return;
        }
        Log.w(TAG + tag, ">>>end<<<" + (System.currentTimeMillis() - startTime));
    }
}
